BaseUrl = "http://192.168.0.102/MicrowoWeb/";
PostDir = "http://192.168.0.102/MicroLive/MicroLive.php";
function getCookie(objName) {
    var arrStr = document.cookie.split("; ");
    for (var i = 0; i < arrStr.length; i++) {
        var temp = arrStr[i].split("=");
        if (temp[0] == objName) {
            return unescape(temp[1])
        }
    }
    return ""
}
function removeAllCookie() {
    var strCookie = document.cookie;
    var arrCookie = strCookie.split("; ");
    for (var i = 0; i < arrCookie.length; i++) {
        var arr = arrCookie[i].split("=");
        if (arr.length > 0) {
            removeCookie(arr[0])
        }
    }
}
function setCookie(name, value, iDay) {
    var oDate = new Date();
    oDate.setDate(oDate.getDate() + iDay);
    document.cookie = name + "=" + value + ";expires=" + oDate.toGMTString() + ";path=/"
}
function removeCookie(name) {
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval = getCookie(name);
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString()
}
function postSubmit(fields, fieldValues) {
    var postUrl = BaseUrl + "index.php";
    var ExportForm = document.createElement("form");
    ExportForm.setAttribute("target", "right");
    document.body.appendChild(ExportForm);
    ExportForm.method = "POST";
    for (var i = 0; i < fields.length; i++) {
        var newElement = document.createElement("input");
        newElement.setAttribute("name", fields[i]);
        newElement.setAttribute("type", "hidden");
        ExportForm.appendChild(newElement);
        newElement.value = fieldValues[i]
    }
    ExportForm.action = postUrl;
    ExportForm.submit()
}
function postSubmitCurrentPage(fields, fieldValues) {
    var postUrl = BaseUrl + "index.php";
    var ExportForm = document.createElement("form");
    document.body.appendChild(ExportForm);
    ExportForm.method = "POST";
    for (var i = 0; i < fields.length; i++) {
        var newElement = document.createElement("input");
        newElement.setAttribute("name", fields[i]);
        newElement.setAttribute("type", "hidden");
        ExportForm.appendChild(newElement);
        newElement.value = fieldValues[i]
    }
    ExportForm.action = postUrl;
    ExportForm.submit()
}
function jumpRightPage(url) {
    window.location.target = "right";
    window.location.href = url
}
function createXmlHttpRequest() {
    var xmlhttp;
    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
        if (xmlhttp.overrideMimeType) {
            xmlhttp.overrideMimeType("text/html")
        }
    } else {
        if (window.ActiveXObject) {
            var activeName = ["MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
            for (var i = 0; i > activeName.length(); i++) {
                try {
                    xmlhttp = new ActiveXObject(activeName[i]);
                    break
                } catch(e) {
                    return null
                }
            }
        }
    }
    return xmlhttp
}
function Delete_tabel(tableName) {
    for (var i = 0; i < 14; i++) {
        $("#" + tableName + " tr:last").remove()
    }
}
function onlyNum() {
    if (! (event.keyCode == 46) && !(event.keyCode == 8) && !(event.keyCode == 37) && !(event.keyCode == 39)) {
        if (! ((event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105))) {
            event.returnValue = false
        }
    }
}
function checkGroupName() {}
function checkUserName() {}
function checkIsChAndNum(str) {
    for (var i = 0; i < str.length; i++) {
        var ch = str.charAt(i);
        if (ch < "0" || ch > "9") {
            if (ch < "a" || ch > "z") {
                if (ch < "A" || ch > "Z") {
                    return false
                }
            }
        }
    }
    return true
}
function checkIsNum(str) {
    for (var i = 0; i < str.length; i++) {
        var ch = str.charAt(i);
        if (ch < "0" || ch > "9") {
            return false
        }
    }
    return true
}
function tishi(i) {
    if (i == 19) {
        alert("19")
    } else {
        if (i == 0) {
            alert("暂不开放")
        }
    }
}
function errorParse(errorCode) {
    switch (errorCode) {
    case "0":
        alert("sucess");
        break;
    case "-1":
        alert("参数太少");
        break;
    case "-2":
        alert("验证失败");
        break;
    case "-3":
        alert("参数有误");
        break;
    case "-4":
        alert("接口类型错误");
        break;
    case "-5":
        alert("系统错误");
        break;
    case "-6":
        alert("系统错误！");
        break;
    case "-7":
        alert("用户ID不存在");
        break;
    case "-8":
        alert("系统错误");
        break;
    case "-9":
        alert("系统错误");
        break;
    case "-10":
        alert("没有任何群组");
        break;
    case "-11":
        alert("此用户已经在这个群了");
        break;
    case "-12":
        alert("此帐号已经存在");
        break;
    case "-13":
        alert("帐号或者密码错误");
        break;
    case "-14":
        alert("此手机号已经绑定用户");
        break;
    case "-15":
        alert("此手机号的用户不存在");
        break;
    case "-16":
        alert("用户不存在");
        break;
    case "-17":
        alert("他们已经是好友");
        break;
    case "-18":
        alert("群成员不存在");
        break;
    case "-19":
        alert("不是群创建者或者群不存在");
        break;
    case "-20":
        alert("打开文件失败");
        break;
    case "-26":
        alert("用户不在线");
        break;
    case "-27":
        alert("通话繁忙");
        break;
    case "-28":
        alert("没有权限");
        break;
    case "-29":
        top.location = BaseUrl + "login.html";
        break;
    case "-30":
        top.location = BaseUrl + "login.html";
        break;
    case "-31":
        alert("代理商名字不存在");
        break;
    case "-32":
        alert("域不存在");
        break;
    case "-33":
        alert("域群组不能超过200个");
        break;
    case "-34":
        alert("群组不存在");
        break;
    case "-35":
        alert("群组成员达到最大(200人)");
        break;
    case "-40":
        alert("此域不存在");
        break;
    case "-41":
        alert("此域没有任何成员");
        break;
    case "-50":
        alert("帐号太长");
        break;
    case "-51":
        alert("密码太长");
        break;
    case "-52":
        alert("名字太长");
        break;
    case "-53":
        alert("域人数超过上限(3200)");
        break;
    case "-54":
        alert("群成员的类型错误");
        break;
    case "-55":
        alert("用户群组数量达到最大");
        break;
    case "-56":
        alert("帐号不存在，或者部分帐号不存在");
        break;
    case "-57":
        alert("域群组数量过多(不能超过1000)");
        break;
	case "-58":
		alert("请输入正确手机号格式！");
		break;
    default:
        alert("未知错误");
        break
    }
}
function makeRequest(keyList, valueList, httpRequest, cb) {
    httpRequest.onreadystatechange = cb;
    httpRequest.open("POST", PostDir, false);
    httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    var timastamp = Date.parse(new Date());
    var token = hex_md5("" + timastamp + "MicroWo20140818");
    var postSessionId = getCookie("session_id");
    var postUserId = getCookie("user_id");
    var sendValue = "timestamp=" + timastamp + "&token=" + token + "&session=" + postSessionId + "&user=" + postUserId;
    for (var i = 0; i < keyList.length; i++) {
        sendValue = sendValue + keyList[i] + valueList[i]
    }
    httpRequest.send(sendValue)
}
function getBytesCount(str) {
    var realLength = 0;
    var len = str.length;
    var charCode = -1;
    for (var i = 0; i < len; i++) {
        charCode = str.charCodeAt(i);
        if (charCode >= 0 && charCode <= 128) {
            realLength += 1
        } else {
            if (charCode >= 128 && charCode <= 2047) {
                realLength += 2
            } else {
                if (charCode >= 2048 && charCode <= 65535) {
                    realLength += 3
                } else {
                    if (charCode >= 65536 && charCode <= 1114111) {
                        realLength += 4
                    } else {
                        realLength += 5
                    }
                }
            }
        }
    }
    return realLength
}
function echo(stringA, stringB) {
    var hello = "你好";
    alert("hello world")
};